#include "contactgroupcontact.h"
#include "account/accountbuddy.h"
#include "account/accountuser.h"

#include <QPixmap>


namespace Contact {

GroupContact::GroupContact(qint64 id, QObject *parent) :
    AbstractContact(parent),
    m_id(id)
{
}


GroupContact::~GroupContact()
{
    m_partnerMap.clear();
}


AbstractContact::Type GroupContact::type() const
{
    return AbstractContact::GroupType;
}


int GroupContact::id() const
{
    return m_id;
}


const GroupContact::PartnerMap &GroupContact::partnerMap() const
{
    return m_partnerMap;
}


bool GroupContact::accept(Account::Buddy *partner)
{
    if (partner == NULL)
        return false;

    qint64 id = partner->id();
    if (m_partnerMap.find(id) != m_partnerMap.end())
        return false;

    m_partnerMap.insert(id, partner);
    return true;
}


bool GroupContact::reject(Account::Buddy *partner)
{
    if (partner == NULL)
        return false;

    qint64 id = partner->id();
    if (m_partnerMap.find(id) == m_partnerMap.end())
        return false;

    m_partnerMap.remove(id);
    return true;
}


bool GroupContact::isAccepted(qint64 id) const
{
    return m_partnerMap.find(id) != m_partnerMap.end();
}


void GroupContact::onDataChanged(Account::Member *member)
{
    Q_UNUSED(member);
    emit dataChanged(this);
}

} // namespace Contact
